<template>
  <div v-if="ROUTES_CHILDREN.length > 0" class="box-crumb">
    <el-breadcrumb separator-class="el-icon-arrow-right" class="app-breadcrumb">
      <transition-group name="breadcrumb">
        <el-breadcrumb-item v-for="(item) in levelList" :key="item.path">
          <a>{{ item.meta.title }}</a>
        </el-breadcrumb-item>
      </transition-group>
    </el-breadcrumb>
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
  data() {
    return {
      levelList: []
    }
  },
  watch: {
    $route(route) {
      this.getBreadcrumb()
    }
  },
  computed: {
    ...mapState('routes_source', ['ROUTES_CHILDREN'])
  },
  created() {
    this.getBreadcrumb()
  },
  methods: {
    // 导航条
    getBreadcrumb() {
      const matched = this.$route.matched.filter(item => item.meta && item.meta.title)
      this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false)
    },
  }
}
</script>
<style lang="scss" scoped>
  .box-crumb{
    .el-breadcrumb{
    height: 55px;
    line-height: 55px;
    padding-left: 20px;
    background-color: #FFFFFF;
  }
  }
</style>

